/<template>
  <div>
    <img :src="$store.state.detail.img" alt="">
    <h3>{{$store.state.detail.title}}</h3>
    <p>
      <b>￥{{$store.state.detail.price}}</b>
      <b>销量：{{$store.state.detail.sales}}</b>
    </p>
    <p>
      <b>数量{{$store.state.detail.num}}</b>
      <span @click="addNum">加入购物车</span>
    </p>
  </div>
</template>

<script>
export default {
  mounted(){
    this.$store.commit('setDetail', this.$route.params.id)
  },
  methods:{
    addNum(){
      this.$store.commit('addNum', this.$route.params.id)
    }
  }
}
</script>

<style>

</style>